﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Com.Library.DB.Menu;

namespace Com.Web.coffinegurunaru.AppLogic
{
	public static class RecommendMenuExtenstion
	{
		public static string GetGenerator(this RecommendMenuEntity info)
		{
			string AnchorHeader = string.Empty;
			string Img = string.Empty;
			string AnchorTail = string.Empty;

			if (info.LinkType != 0)
			{
				if (info.Link != string.Empty)
				{
					AnchorHeader = "<a href=\"" + info.Link + "\" target=\"" + (info.LinkType == 1 ? "_self" : "_blank") + "\" >";
					AnchorTail = "</a>";
				}
			}
			Img = "<img src=\"" + info.ImageURL + "\" />";

			return AnchorHeader + Img + AnchorTail;
		}

		public static string GetGenerator(this RecommendMenuEntity info, int Width)
		{
			string AnchorHeader = string.Empty;
			string Img = string.Empty;
			string AnchorTail = string.Empty;

			if (info.LinkType != 0)
			{
				if (info.Link != string.Empty)
				{
					AnchorHeader = "<a href=\"" + info.Link + "\" target=\"" + (info.LinkType == 1 ? "_self" : "_blank") + "\" >";
					AnchorTail = "</a>";
				}
			}
			if (Width == 0)
			{
				Img = "<img src=\"" + info.ImageURL + "\" />";
			}
			else
			{
				Img = "<img src=\"" + info.ImageURL + "\" width=\"" + Width.ToString() + "\" />";
			}

			return AnchorHeader + Img + AnchorTail;
		}
	}
}
